package com.zr.planClass.mapper;

import com.zr.planClass.model.PlanClassSelectVo;
import com.zr.planClass.model.PlanClassVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Service;

import javax.validation.constraints.NotBlank;
import java.util.List;

/**
 * Created by Hasee on 2019/12/20.
 */
@Mapper
public interface PlanClassMapper {
    @Select("select count(id) from planclass where name = #{name}")
    int queryByName( String name);
    @Select("select * from planclass where name = #{name}")
    List<PlanClassVo> queryByName2( String name);
    @Select("select count(id) from planclass where code = #{code}")
    int queryByCode( String code);

    @Insert("insert into planclass (name,code,remark,status) values (#{name},#{code},#{remark},#{status})")
    void addPlanClass(PlanClassVo planClassVo);

    @Select("select * from planclass where id=#{id}")
    PlanClassVo queryById(Integer id);

    @Update("update planclass set name=#{name},status=#{status},updateName=#{updateName},version=#{version}+1 where id=#{id} and version=#{version}")
    int updatePlanClass(PlanClassVo planClassVo);

    @Update("update planclass set status=#{status},updateName=#{updateName} where id=#{id}")
    void updatePlanClassStatus(PlanClassVo planClassVo);

    List<PlanClassVo> queryPageData(PlanClassSelectVo planClassSelectVo);

    int queryPageCount(PlanClassSelectVo planClassSelectVo);
}
